<?php

namespace App\Services;

use App\Services\WechatApi\WechatApiOffiAccount;
use Illuminate\Http\Request;

class WxMaterialService extends ServiceBase
{
    public function batchGetMaterial($appid, $params)
    {
        if (empty($params)) {
            return 7018;
        }

        $wx_config = WxConfigService::getInstance()->one($appid);
        if (!$wx_config) {
            return 7019;
        }

        $access_token = WechatService::getInstance()->getAccessToken($wx_config->appid, $wx_config->secret);
        if (!$access_token) {
            return 7020;
        }

        $res = WechatApiOffiAccount::getInstance()->batchGetMaterial($access_token, $params);
        if (!is_array($res)) {
            return 7021;
        }

        return $res;
    }
}
